package com.zoe.wan.android.example.repository

import com.zoe.wan.android.example.repository.data.*
import com.zoe.wan.android.http.ApiAddress
import com.zoe.wan.android.http.BaseResponse
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {

    /**
     *  首页列表数据
     */
    @GET("${ApiAddress.Article_List}{pageCount}/json")
    suspend fun homeList(@Path("pageCount") pageCount: String): BaseResponse<HomeListData?>?

    @GET(ApiAddress.Home_Banner)
    suspend fun homeBanner(): BaseResponse<HomeBannerData?>?

    @FormUrlEncoded
    @POST(ApiAddress.Login)
    suspend fun login(
        @Field("username") username: String,
        @Field("password") password: String
    ): BaseResponse<UserData?>?

    @FormUrlEncoded
    @POST(ApiAddress.Register)
    suspend fun register(
        @Field("username") username: String,
        @Field("password") password: String,
        @Field("repassword") rePassword: String
    ): BaseResponse<UserData?>?


    /**
     * 退出登录
     */
    @GET(ApiAddress.Logout)
    suspend fun logout(): BaseResponse<Any?>?

    /**
     * 收藏文章
     */
    @POST(ApiAddress.Collect + "{id}/json")
    suspend fun collect(@Path("id") id: String): BaseResponse<Any?>?

    /**
     * 取消文章
     */
    @POST(ApiAddress.Collect_Cancel + "{id}/json")
    suspend fun cancelCollect(@Path("id") id: String): BaseResponse<Any?>?


    /**
     * 置顶列表数据
     */
    @GET(ApiAddress.Top_Article_List)
    suspend fun topHomeList(): BaseResponse<HomeTopListData?>?


    /**
     * 体系数据
     */
    @GET(ApiAddress.Knowledge_List)
    suspend fun knowledgeList(): BaseResponse<KnowledgeListData?>?

    /**
     * 体系下文章列表
     */
    @GET("${ApiAddress.Knowledge_List_detail}{pageCount}/json")
    suspend fun knowledgeArticleList(
        @Path("pageCount") pageCount: String = "0",
        @Query("cid") cid: String
    ): BaseResponse<KnowledgeDetailArticleListData?>?


    /**
     * 搜索热词
     */
    @GET(ApiAddress.Search_Hot_Key)
    suspend fun searchHotKeyList(): BaseResponse<SearchHotKeyListData?>?

    /**
     * 常用网站
     */
    @GET(ApiAddress.Common_Use_Website)
    suspend fun commonWebsiteList(): BaseResponse<CommonWebsiteListData?>?

    /**
     * 搜索文章
     */
    @FormUrlEncoded
    @POST("${ApiAddress.Search}{pageCount}/json")
    suspend fun search(
        @Field("k") k: String,
        @Path("pageCount") pageCount: String = "0"
    ): BaseResponse<SearchResultListData?>?

    /**
     * 我的收藏
     */
    @GET("${ApiAddress.My_Collect}{pageCount}/json")
    suspend fun myCollect(@Path("pageCount") pageCount: String = "0"): BaseResponse<MyCollectListData?>?

}